<?php
/** Admin_email 
	* 
	* @package Pharmacy Intervention 
	* @subpackage Controller
	* @category Administrative
	* @author Ray Nowell */  
class Admin_email  extends MY_Controller 
{
  
	function Admin_email()
	{
		parent::MY_Controller(MUST_BE_ADMIN);
	}
  	//REN TODO:  Big problems with this right now.  
  	//           You can look at the form and tell it needs work
  	//           I have issues with the Text Area not posting correct
  	//           Plus, it would be better to select users and not just e-mail myself
  	//           Just a prototype to show proof of concept.
	function index()
	{
		
		$this->load->helper('form');
		
		$data['subject_input'] = array(	'id'=>'_subject',
										'name' => 'subject',
									  	'value'=> '',
										'size'=>'50',
										'autocomplete'=>'off',);
		
		$data['message_input'] = array(	'id'=>'_message',
										'name' => 'message',
									  	'value'=> '',
										'size'=>'50',
										'autocomplete'=>'off',);
		
		//REN TODO:  Post on Text area not working (grrr!)...just using a standard input box for now
//		$data['message_text_area']	=	array('name'	=>	'messsage',
//		                                		'id'	=>	'_messsage',
//												'value'	=>	'',
//												'rows'	=>	'14',
//												'cols'	=>	'47',);
		$data['additional_javascript_doc_ready_functions'] = '$(".submit-button", ".auth-div").button();$(\'#_subject\').focus();';
		$data['title'] = COMPANY_NAME." -- Send Announcment";
		$data['heading'] = "Send Announcment";	 
		$data['view'] = 'admin_email_view';
		$this->load->vars($data);
		$this->load->view('master_view', $data);  
			
	}
	
	function send()
	{
		$this->load->library('email');
		
		$subject	=	$this->input->post('subject');
		$message	=	$this->input->post('message');
		
		$this->email->from('TEST@test.com', 'Ray');
		$this->email->to('ray023@gmail.com');
		//$this->email->cc('another@another-example.com');
		//$tis->email->bcc('them@their-example.com');
		
		$this->email->subject($subject);
		$this->email->message($message);
		
		$this->email->send();
		
		$this->load->helper('form');
		
		$data['subject_input'] = array(	'id'=>'_subject',
										'name' => 'subject',
									  	'value'=> '',
										'size'=>'50',
										'autocomplete'=>'off',);
		
		$data['message_input'] = array(	'id'=>'_message',
										'name' => 'message',
									  	'value'=> '',
										'size'=>'50',
										'autocomplete'=>'off',);
		
		//REN TODO:  Post on Text area not working (grrr!)...just using a standard input box for now
//		$data['message_text_area']	=	array('name'	=>	'messsage',
//		                                		'id'	=>	'_messsage',
//												'value'	=>	'',
//												'rows'	=>	'14',
//												'cols'	=>	'47',);
		$data['additional_javascript_doc_ready_functions'] = '$(".submit-button", ".auth-div").button();$(\'#_subject\').focus();';
		$data['title'] = COMPANY_NAME." -- Send Announcment";
		$data['heading'] = "Send Announcment";	 
		$data['view'] = 'admin_email_view';
		$this->load->vars($data);
		$this->load->view('master_view', $data);   
		
  			
	}
	
  
}  
/* End of file admin_email.php */
/* Location: ./system/application/controllers/admin_email.php */
